<template>
	<view v-if="img" class="start_pages" :style="showBkColor?'background-color: #191919;':'background-color: #ffffff;'">
		<image @load="loadImg" class="start_imgs" :src="picUrl+img" mode="aspectFill"></image>
		<view class="weui-badge" :style="'bottom:'+pdbottom+'rpx;'" @click="goHome" v-if="showBkColor">跳过 ({{time}})
		</view>
	</view>
</template>

<script>
	import {
		getList,
	} from '@/api/motortime.js';
	let app = getApp()
	export default {
		data() {
			return {
				img: '',
				time: 5,
				timerd: '',
				timeout: '',
				showBkColor: false,
				picUrl: app.globalData.picUrl,
				onlinePic: app.globalData.onlinePic,
				pdbottom: uni.getSystemInfoSync().safeAreaInsets.bottom + 80,
			};
		},
		onShow() {
			setTimeout(() => {
				uni.hideHomeButton()
			}, 100);
		},
		onLoad() {
			var that = this
			setTimeout(() => {
				if (uni.getStorageSync('clubconfig').start) {
					that.img = uni.getStorageSync('clubconfig').start.img
					that.time = uni.getStorageSync('clubconfig').start.time
				} else {
					uni.switchTab({
						url: '/pages/index/index'
					})
				}
			}, 10);
			var params = {
				event_code: '开屏页',
				path: 'pages/start/start',
				event_id: '',
				title: '',
				source_page: '',
				value: uni.getStorageSync('Appoptions').query ? uni
					.getStorageSync('Appoptions').query.register_channel : '',
			}
			app.BurialPoint(params)
		},
		methods: {
			loadImg() {
				var that = this
				that.showBkColor = true

				that.timeout = setTimeout(function() {
					uni.switchTab({
						url: '/pages/index/index'
					})
				}, 5000)
				var time = that.time
				that.timerd = setInterval(function() {
					if (time > 0) {
						time--
						that.time = time
					}
				}, 1000);
			},
			goHome() {
				var params = {
					event_code: '开屏页',
					path: 'pages/start/start',
					event_id: '',
					title: '',
					source_page: '开屏页-点击跳过',
					value: '',
				}
				app.BurialPoint(params)
				uni.switchTab({
					url: '/pages/index/index'
				})
				clearTimeout(this.timeout)
			}
		},
		onHide() {
			clearTimeout(this.timeout)
		},
		onShareAppMessage(res) {
			app.getShareTask()
			return {

			}
		},
		onShareTimeline: function() {
			app.getShareTask()
			return {

			}
		},
	}
</script>

<style lang="scss">
	.start_pages {
		height: 100vh;
		position: relative;

		.start_img {
			width: 100%;
			vertical-align: middle;
		}

		.start_imgs {
			width: 100%;
			height: 100vh;
			vertical-align: middle;
		}

		.weui-badge {
			width: 130rpx;
			float: right;
			position: absolute;
			right: 40rpx;
			background-color: #000;
			opacity: 0.6;
			padding: 12rpx 0;
			display: inline-block;
			min-width: 8px;
			border-radius: 18px;
			color: #fff;
			line-height: 1.2;
			text-align: center;
			font-size: 12px;
			vertical-align: middle;
			z-index: 1000;
		}
	}
</style>